<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>tabs切换</title>
    <style>
        body,ul,li {
            margin: 0;
            padding: 0;
            list-style: none;
        }
        .title {
            display: flex;
        }
        .title li {
            margin-right: 15px;
            cursor: pointer;
        }
        .title .active {
            color: red;
        }

        .content li {
            display: none;
        } 

        .content .active {
            display: block !important;
        }
    </style>
</head>
<body>
    <ul class="title">
        <li class="active">社会</li>
        <li>经济</li>
        <li>体育</li>
        <li>科技</li>
    </ul>

    <ul class="content">
        <li class="active">社会 的内容</li>
        <li>经济 的内容</li>
        <li>体育 的内容</li>
        <li>科技 的内容</li>
    </ul>
</body>
<script>
    let titleLi = document.querySelectorAll(".title li");
    let contentLi = document.querySelectorAll(".content li");

    titleLi.forEach(function(v,i) {
        v.onclick = function () {
            titleLi.forEach(function(val,index) {
                val.className = ""
                contentLi[index].className = ""
            })
            v.className = "active"
            contentLi[i].className = "active"
        }
    })
</script>
</html>